import * as chapter from '../services/chapter'

export default {
    namespace: 'chapter',
    state: {
        content: '',
    },
    reducers: {
        get_content(state, action) {
            console.log(action)
            return {
                ...state,
                content: action.data.chapter.body
            }
        },
        clear_content(state) {
            return {
                ...state,
                content: null
            }
        },
    },
    effects: {
        * POST_GET(action, { call, put }) {
            const { data } = yield call(chapter.getChapters)
            yield put({ type: 'get_content', data })
        },
        * POST_logout(action, { call, put }) {
            // const { data } = yield call(user.postLogin)
            yield put({ type: 'logout' })
        },
    },
}
